<script>
    var ajaxUrl = '<?php echo Yii::app()->createUrl('ajax/xupload') ?>';
    var countImages = '<?php echo count($images); ?>';
</script>
<script type="text/javascript" src="<?php echo Yii::app()->request->baseUrl; ?>/js/preview.js"></script>
<script type="text/javascript">
    tinyMCE.init({
        mode : "exact",
        elements : "editor",
        theme : "advanced",
        skin : "default",
        width : "81%",
        height : "210",
        invalid_elements: "img, a, script, h1, h2, h3, h4, h5, h6, h7, font, iframe, object",
        theme_advanced_buttons1 : "bold,italic,underline,strikethrough,|,justifyleft,justifycenter,justifyright,justifyfull",
        theme_advanced_toolbar_location : "top",
        theme_advanced_toolbar_align : "left",
        theme_advanced_statusbar_location : "bottom",
        theme_advanced_resizing : false,
        theme_advanced_path : false
    });
</script>

<?php $this->renderPartial('//partials/partnerMenu', array('partner'=>$partner, 'advertCode'=>$advertCode, 'cat'=>$cat, 'userIsWork'=>$userIsWork, 'errorModel'=>$errorModel, 'relProfiles'=>$relProfiles, 'subCats'=>$subCats, 'show_tabs'=>1,'curent'=>'forum'));?> 
<hr/>

<div class="well">
    <div style="display:none"><?php echo $model->themeId;?></div>
    <h2><a href=""><?php echo $model->title; ?></a></h2>
    <span class="date"><?php echo Yii::app()->dateFormatter->format("dd MMMM yyyy года в HH:mm", $com['comDate']); ?></span>&nbsp;
    <a class="commentByName" href="#form"><?php echo !empty($com['login']) ? !empty($com['displayName']) ? $com['displayName'] : $com['login'] : 'Гость'; ?></a>&nbsp;
    <?php if($model->isSupport) : ?>
        <img src="/images/prettyImg/supQue.jpg" />
    <?php endif;?>
    <br/>
    <div class="messageText">
        <?php echo $com['text']; ?>
    </div>

    <?php if(!empty($images)) : ?>
        <?php foreach($images as $item) : ?>
            <a href="#" class="big-link" data-reveal-id="modal<?php echo $item['imgId']; ?>" data-animation="fade">
                <img src="<?php echo Yii::app()->baseUrl.'/images/uploads/comments/'.$item['smallImg']; ?>"/>
            </a>     
            <div id="modal<?php echo $item['imgId']; ?>" class="reveal-modal">
                <img src="<?php echo Yii::app()->baseUrl.'/images/uploads/comments/'.$item['bigImg']; ?>"/>
                <a class="close-reveal-modal">&#215;</a>
            </div>
        <?php endforeach; ?>
    <?php endif; ?>
    <br/><br/>

    <span style="float: left; padding-right: 20px">
        <span style="color:violet; cursor: pointer">Ответить</span>
    </span>

    <span style="cursor: pointer">
        <span style="color:violet; cursor: pointer">Цитировать</span>
    </span>
</div>

    <?php echo CHtml::errorSummary($model, 'Пожалуйста исправьте следующие ошибки:'); ?>
    
    <?php echo CHtml::beginForm(); ?>
        <br/><br/>
        Текущие изображения. Клик - удалить:
        <div class="inline">
            <?php foreach($images as $comImg) : ?>
                <img style="cursor:pointer" class="loadedImg" src="<?php echo Yii::app()->baseUrl.'/images/uploads/comments/'.$comImg['smallImg']; ?>"/>
            <?php endforeach; ?>
        </div>
        <?php echo CHtml::activeHiddenField($model, 'deletedImg', array('value'=>'1', 'id'=>'deletedImg')); ?>
        <br/><br/>
        <div class="newThemeForm" style="background-color:wheat; ">
            <?php $userId = Yii::app()->user->isGuest ? Yii::app()->user->getId() : 0 ; ?>
            
            <?php echo CHtml::activeLabel($model, 'title'); ?>
            <?php echo CHtml::activeTextField($model, 'title', array('style'=>'width:80%')); ?>

            <?php $model->text = $com['text']; ?>
            <?php echo CHtml::activeLabel($model, 'text'); ?>
            <?php echo CHtml::activeTextArea($model, 'text', array('style'=>'width:80%;height:200px;', 'id'=>'editor')); ?>

            <?php echo CHtml::activeHiddenField($model, 'partnerId', array('value'=>$partner['partnerid'], 'id'=>'partnerId')); ?>
            <?php echo CHtml::activeHiddenField($model, 'firstComId', array('value'=>$com['comId'])); ?>
            <?php echo CHtml::activeHiddenField($model, 'type', array('value'=>'forum')); ?>
            <br/>
            <?php echo CHtml::submitButton('Сохранить изменения', array('class'=>'btn btn-large btn-primary')); ?>
            <a href="" class="btn btn-large btn-primary">Отменить изменения</a>
            <br/><br/>
            <div id="fileUpload">
                <?php $this->widget('xupload.XUpload', array(
                    'url' => Yii::app()->createUrl("partner/forum/upload"),
                    'model' => new XUploadForm, 
                    'attribute' => 'file',
                    'showForm' => false,    
                    'multiple' => true,
                    'options' => array( 
                        'autoUpload' => true, 
                        'maxNumberOfFiles' => !empty($images) ? 5 - count($images) : 5, 
                        'maxFileSize' => 500000,
                        'acceptFileTypes' => "js:/(\.|\/)(jpe?g|png|gif)$/i",
                    ),
                    'downloadView'=>'downloadViewOrigin',
                    'htmlOptions' => array(
                        'id' => 'fileUpload',
                    ),
                ));  ?>
            </div>
        </div>
    <?php echo CHtml::endForm(); ?> 